package com.soft.javase.day06.regex;

import java.util.Scanner;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/24
 */
public class ValidUsername {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名(6-12位，以字母开头，只能包含字母、数字和下划线):");
        String username = sc.nextLine();

        String regex = "^[a-zA-Z][a-zA-Z0-9_]{5,11}$";
        if (username.matches(regex)) {
            System.out.println("用户名有效");
        }else {
            System.out.println("用户名无效");
        }

    }
}
